import request from '@/config/axios'
const { VITE_BASE_URL, VITE_API_URL } = import.meta.env;
const base_url = `${VITE_BASE_URL}${VITE_API_URL}`;
export interface ProfileVO {
  id: number
  username: string
  nickname: string
  dept: {
    id: number
    name: string
  }
  roles: {
    id: number
    name: string
  }[]
  posts: {
    id: number
    name: string
  }[]
  socialUsers: {
    type: number
    openid: string
  }[]
  email: string
  mobile: string
  sex: number
  avatar: string
  status: number
  remark: string
  loginIp: string
  loginDate: Date
  createTime: Date
}

export interface TiktokUserInfoVO {
    avatarUrl:string
    //昵称
    displayName:string
    //用户的用户名
    username:string
    //用户关注数
    followerCount:number
    //用户关注的帐号数
    followingCount:number
    //用户在所有视频中收到的点赞总数
    likesCount:number
    //该用户公开发布的视频总数
    videoCount:number
}

export interface UserProfileUpdateReqVO {
  nickname: string
  email: string
  mobile: string
  sex: number
}

// 查询用户个人信息
export const getUserProfile = () => {
  return request.get({ url: '/system/user/profile/get' })
}
// 查询用户tiktok信息
export const getTiktokUserInfo = () => {
  return request.get({ url: '/tiktok/userinfo' })
}
// 修改用户个人信息
export const updateUserProfile = (data: UserProfileUpdateReqVO) => {
  return request.put({ url: '/system/user/profile/update', data })
}

// 用户密码重置
export const updateUserPassword = (oldPassword: string, newPassword: string) => {
  return request.put({
    url: '/system/user/profile/update-password',
    data: {
      oldPassword: oldPassword,
      newPassword: newPassword
    }
  })
}

// 用户头像上传
export const uploadAvatar = (data) => {
  return request.upload({ url: '/system/user/profile/update-avatar', data: data })
}

export const tiktokAuthUrl = ()=>{
  return base_url +"/tiktok/auth"
}
